// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GripState.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Microsoft.Robotics.Manipulation.PicknPlace
{
    using System;
    using System.Runtime.Serialization;
    using Microsoft.Robotics.Numerics;

    /// <summary>
    /// Captures the geometry and style of a grip to provide a minimal description of 
    /// a grip for a gripper that has a palm and "fingers"
    /// </summary>
    [DataContract]
    public class GripState 
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GripState" /> class
        /// </summary>
        /// <param name="gripStyle">Type of grip</param>
        /// <param name="gripCenterGlobalLocation">centre of grip point along the gripAxis</param>
        /// <param name="palmPlaneNormal">Normal to the gripper palm plane. Note the plane is not fully specified 
        /// as it just provides the normal direction.</param>
        /// <param name="gripAxis">Gripping axis. gripCenterGlobalLocation lies along this axis and the and the axis must lie within
        /// the palmPlane, that is orthogonal to palmPlaneNormal</param>
        public GripState(
            GripStyle gripStyle,
            Vector3 gripCenterGlobalLocation,
            Vector4 palmPlaneNormal,
            Vector3 gripAxis)
        {
            this.GripStyle = gripStyle;
            this.GripCenterGlobalLocation = gripCenterGlobalLocation;
            this.PalmPlane = palmPlaneNormal;
            this.GripCenterAxis = gripAxis;
        }

        /// <summary>
        /// Gets the grip style
        /// </summary>
        [DataMember]
        public GripStyle GripStyle { get; private set; }

        /// <summary>
        /// Gets the center of the grip. Depends on the grip type but generally specifies a point
        /// on the Grip axis
        /// </summary>
        [DataMember]
        public Vector3 GripCenterGlobalLocation { get; private set; }

            /// <summary>
        /// Gets the gripper's palm plane, represented in normalized homogeneous coordinates
        /// </summary>
        [DataMember]
        public Vector4 PalmPlane { get; private set; }

            /// <summary>
        /// Gets the grip axis. grip axis specifies the orientation of the gripper with respect to the fingers.
        /// For example for a wrap around grip it is the axis the fingers envelope
        /// </summary>
        [DataMember]
        public Vector3 GripCenterAxis { get; private set; }
    }
}
